package com.baikeyang.app.controller.admin;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by lenovo on 2018/7/12.
 */
@RestController(value = "adminController")
@RequestMapping(value = "/admin")
public class AdminController {

    @RequestMapping(value = "")
    public ModelAndView defaultPage () {
        System.out.println("defaultPage");
        return new ModelAndView("forward:/admin/index");
    }

    @RequestMapping(value = "index")
    public ModelAndView index() {
        System.out.println("欢迎进入后台管理系统 index");
        return new ModelAndView("index");
    }

    @RequestMapping(value = "indexBoard")
    public ModelAndView board(HttpServletRequest request) {
        String JDKVERSION = System.getProperty("java.version");
        String JDKMODEL = System.getProperty("sun.arch.data.model");
        String OSNAME = System.getProperty("os.name");
        String SERVERNAME = request.getServletContext().getServerInfo();
//        System.out.println(System.getProperty("java.version"));; //判断JDK版本
//        System.out.println(System.getProperty("sun.arch.data.model"));; //判断是32位还是64位
//        System.out.println(System.getProperty("user.name"));// 获得操作系统帐号
//        Properties props=System.getProperties(); //获得系统属性集
//        String osName = props.getProperty("os.name"); //操作系统名称
//        String osArch = props.getProperty("os.arch"); //操作系统构架
//        String osVersion = props.getProperty("os.version"); //操作系统版本
//        System.out.println(osName);
//        System.out.println(osArch);
//        System.out.println(osVersion);
        return new ModelAndView("admin/board/index-board")
            .addObject("JDKVERSION", JDKVERSION)
            .addObject("JDKMODEL", JDKMODEL)
            .addObject("OSNAME", OSNAME)
            .addObject("SERVERNAME", SERVERNAME);

    }

    @RequestMapping(value = "{urPath}.html")
    public ModelAndView goPgae(@PathVariable("urPath")String urPath) {
        return new ModelAndView("demo/index-" + urPath);
    }

}
